<div class="form-horizontal">
	<div class="form-group">
    	<label class="control-label col-lg-3" for="server">目标服务器</label>
        <div class="col-lg-9">
        	<input type="text" class="form-control" id="migrateUrl" placeholder="http://localhost:8100"/>
        </div> 
    </div>
    
    <div class="form-group">
    	<label class="control-label col-lg-3" for="name">用户名</label>
        <div class="col-lg-9">
        	<input type="text" class="form-control" id="migrateUser" placeholder="目标服务器系统管理员账号" />
        </div> 
    </div>

    <div class="form-group">
    	<label class="control-label col-lg-3" for="password">密码</label>
        <div class="col-lg-9">
        	<input type="password" class="form-control" id="migratePwd" placeholder="目标服务器系统管理员密码"/>
        </div> 
    </div>
    
    <div class="form-group">
    	<label class="control-label col-lg-3" for="path">仓库位置</label>
        <div class="col-lg-9">
        	<input type="text" class="form-control" id="migratePath" placeholder="如使用目标服务器默认仓库位置，请留空！"/>
        </div>
    </div>
	
	<div class="form-group">
		<label class="control-label col-lg-3" for="type">仓库冲突 解决方案</label>
       	<div class="col-lg-9" style="margin-top:10px;">
			<select class="form-control" id="migrateConflictSolution" onchange="doSelectMigrateConflictSolution();" style="width: 100%">   
				<option value="0" selected="selected">自动跳过</option>   
				<option value="1">强制覆盖</option>
				<option value="2">新建仓库</option>   
			</select>
       </div>
	</div>
    
    <div class="form-group">
    	<label class="control-label col-lg-3" for="info">迁移信息</label>
        <div class="col-lg-9">
        	<textarea type="text" class="form-control" id="systemMigrateInfo" disabled="disabled" />
        </div>
    </div>
        
    <!-- Buttons -->
    <div class="form-group">
    	<div class="col-lg-offset-9 col-lg-2">
        	<button id="systemMigrateBtn" type="submit" class="btn btn-success" onclick="doSystemMigrate()">开始迁移</button>
        </div>
    </div>
 </div>
 
<script src="js/base64.js"></script>
<script type="text/javascript">
	var migrateReposesInfo = {};
	function SystemMigrateConfirmPageInit(reposList)
	{
		console.log("SystemMigrateConfirmPageInit()");
		migrateReposesInfo.reposList = reposList;

		var reposListInfo = "";
		var reposIds = "";
		for( var i = 0 ; i < reposList.length ; i++ )
		{
			var repos = reposList[i];
			reposListInfo += "[" + repos.id + "] " + repos.name + ";  \n";
			reposIds += repos.id + ",";
		}
		migrateReposesInfo.reposListInfo = reposListInfo;
		migrateReposesInfo.reposIds = reposIds;
		$("#systemMigrateInfo").val(reposListInfo);
	}
	
	function showSystemMigrateConfirmModal(text){
		$(".systemMigrateConfirmModal").fadeIn("slow");
	}
	
	function closeSystemMigrateConfirmModal(){
		$(".systemMigrateConfirmModal").fadeOut("slow");
	}
	
	function doSystemMigrate()
	{
		console.log("doSystemMigrate");
		
		var serverUrl = $("#migrateUrl").val();
		var user = $("#migrateUser").val();
		var pwd =  base64_encode($("#migratePwd").val());
		var reposStorePath = $("#migratePath").val();
		var conflictSolution = $("#migrateConflictSolution").val();
		var reposIds = migrateReposesInfo.reposIds;
		
		if(!serverUrl)
		{
	    	alert("目标服务器不能为空！");
	    	return false;
		}
		
        $.ajax({
            url : "/DocSystem/Bussiness/systemMigrate.do",
            type : "post",
            dataType : "json",
            data : {
            	serverUrl : serverUrl,
            	user : user,
            	pwd : pwd,
            	reposStorePath : reposStorePath,
            	conflictSolution: conflictSolution,
            	reposIds: reposIds,
            },
            success : function (ret) {
                if( "ok" == ret.status )
                {
                	console.log("doSystemMigrate ret:", ret);
                    $("#systemMigrateBtn").text("系统迁移完成");
                    $("#systemMigrateInfo").val(ret.dataEx.info);
                	//alert("系统迁移完成");
                }else {
                	alert("错误：" + ret.msgInfo);      
                }
            },
            error : function () {
            	alert("服务器异常:系统迁移失败");
            }
        });
        
        //将确定按键的文字修改掉
        $("#systemMigrateBtn").attr("disabled",true);
        $("#systemMigrateBtn").text("系统迁移中...");        
    }
					
	//页面初始化代码    
    $(function(){
    	console.log("systemMigrateConfirm Page init");
    });
</script>